#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/3/18 10:37 AM
# @Author  : qichen

# 用于测试agent的badcase
# 【注意】只要调整了agent，一定要测试一下表现，本文档先用收集的badcase里的来测试，输出结果后自己去对比！！！
# 建议再手动加几个想测的case进去，一起测试

import os
import sys
current_script_path = os.path.abspath(__file__)
work_path = os.path.normpath(os.path.join(current_script_path, '../../../../'))
sys.path.append(work_path)

import pandas as pd
from bot.insurance_planner_gpt.agent.base_agent import LLMAgent
import asyncio


class TestModel(LLMAgent):
    def __init__(self, test_prompt):
        self.prompt = test_prompt
        super().__init__(self.prompt)


if __name__ == "__main__":
    # nohup python ./bot/insurance_planner_gpt/agent/make_local_data/badcase_test.py >> qc_agent_test.log 2>&1 &
    df_badcase = pd.read_csv(work_path+'/train_data/20240514-case.csv')
    df_testcase = df_badcase.copy()
    result = []
    for test_prompt in df_testcase['prompt']:
        testmodel = TestModel(test_prompt)
        result_self = asyncio.run(testmodel.achat_auto_llm(type="self"))
        result.append(result_self)
        # print('\n result_self:\n',result_self)
    df_testcase['test新模型结果'] = result
    df_result = df_testcase[['prompt','test新模型结果', '正确答案',  '错误agent', '问题描述' ]]
    from datetime import datetime
    now = datetime.now()
    time_str = now.strftime("%Y-%m-%d-%H-%M")
    # 写到excel
    df_result.to_excel(work_path + '/train_data/' + time_str + '-测试结果.xlsx', index=False, encoding='utf-8-sig')
    # df_result.to_csv(work_path+'/train_data/'+time_str+'-测试结果.csv', index=False, encoding='utf-8-sig')








